package com.giornoadd.timex.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.giornoadd.timex.util.ApplicationSecurityManager;

/**
 * Controller for "signing out" of the application.
 * @author anil
 */
@Controller
@RequestMapping("/signOut")
public class SignOutController
{
	@Autowired
    private ApplicationSecurityManager applicationSecurityManager;

    /**
     * Removes Employee object from session using ApplicationSecurityManager.
     * @see ApplicationSecurityManager 
     */
	@RequestMapping(method=RequestMethod.GET)
    public ModelAndView handleRequest(HttpSession session)
    {
        applicationSecurityManager.removeEmployee(session);
        return new ModelAndView(new RedirectView("signIn"));
    }

    public ApplicationSecurityManager getApplicationSecurityManager()
    {
        return applicationSecurityManager;
    }

    public void setApplicationSecurityManager(
            ApplicationSecurityManager applicationSecurityManager)
    {
        this.applicationSecurityManager = applicationSecurityManager;
    }
}
